package cn.school.controller.classManage;

import cn.school.classManage.dao.SchoolClassDao;
import cn.school.classManage.entity.ClassCurriculumMiaosu;
import cn.school.classManage.entity.ClassCurriculumUser;
import cn.school.classManage.service.ClassCurriculumMiaosuService;
import cn.school.classManage.service.ClassCurriculumUserService;
import cn.school.classManage.service.SchoolClassService;
import cn.school.classManage.vo.SchoolClassVO;
import cn.school.common.api.CommonResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/classInfo")
@Api(tags = "个人课表")
public class ClassCurriculumUserController {
    @Resource
    ClassCurriculumUserService classCurriculumUserService;
    @Resource
    SchoolClassService schoolClassService;
    @Resource
    SchoolClassDao schoolClassDao;
    @Resource
    ClassCurriculumMiaosuService classCurriculumMiaosuService;

    @PostMapping("/findCurriculumUser")
    @ApiOperation("分页查询个人课表")
    public CommonResult<List<ClassCurriculumUser>> findClassUser(@RequestBody ClassCurriculumUser user){
        List<ClassCurriculumUser> curriculumUserList = classCurriculumUserService.getUserList(user);
        return CommonResult.success(curriculumUserList);
    }

    @GetMapping("/schoolClassList")
    @ApiOperation("查询个人班级")
    public CommonResult<List<SchoolClassVO>> schoolClassList(){
        List<SchoolClassVO> classInfo =  schoolClassDao.findAllSchoolClass(null);
        return CommonResult.success(classInfo);
    }

    @PostMapping("/addOrUpdateUser")
    @ApiOperation("新增or修改个人班级课表")
    public CommonResult<ClassCurriculumUser> add(@RequestBody List<ClassCurriculumUser> userList){
        int num =classCurriculumUserService.addAllCurriculumUser(userList);
        if(num>0){
            return CommonResult.success();
        }
        return CommonResult.failed();
    }



    @PostMapping("/findListMiaosu")
    @ApiOperation("查询所有数据")
    public CommonResult<List<ClassCurriculumMiaosu>> findmMiaosu(){
        List<ClassCurriculumMiaosu> curriculumMiaosus = classCurriculumMiaosuService.selectAll();
        return CommonResult.success(curriculumMiaosus);
    }

    @PostMapping("findMiaosu")
    @ApiOperation("查询个人描述")
    public CommonResult<ClassCurriculumMiaosu> findMiaoShu(@RequestBody ClassCurriculumMiaosu miaosu){
        ClassCurriculumMiaosu miaosus=classCurriculumMiaosuService.selectMonday(miaosu);
        return CommonResult.success(miaosus);
    }

    @PostMapping("addMiaoshu")
    @ApiOperation("新增OR修改")
    public CommonResult<Integer> addMiaoShu(@RequestBody ClassCurriculumMiaosu miaosu){
        Integer integer = classCurriculumMiaosuService.addMiaoShu(miaosu);
        return CommonResult.success(integer);
    }


}
